<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>添加城市</span>
      </div>
      <From :form="form">
        <el-form-item>
          <el-button type="primary" @click="onSubmit" :loading="loading">立即创建</el-button>
        </el-form-item>
      </From>
    </el-card>
  </div>
</template>


<script>
import From from "./From";
export default {
  data() {
    return {
      loading: false,
      //存放表单数据
      form: {}
    };
  },
  components: {
    From
  },
  methods: {
    async onSubmit() {
      let url = "/city/add";
      let data = this.form;
      try {
        this.loading = true;
        let res = await this.$axios.post(url, this.form);
        this.$message({
          message: "添加城市成功",
          type: "success"
        });

        //设置跳转
        setTimeout(() => {
          //
          this.$router.push({
            path: "/city/list"
          });
        }, 1000);
      } catch (error) {}
      this.loading = false;
    }
  }
};
</script>
<style>
.fond {
  font-size: 13.5px;
}
</style>